package com.gu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gu.entity.CrmBanner;
import com.gu.service.CrmBannerService;
import com.gu.mapper.CrmBannerMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner>
    implements CrmBannerService{

    @Override
    public List<CrmBanner> getAll() {
        //只显示一页中 排序最高的3张
        Page<CrmBanner> bannerPage = new Page<>(1,3);
        QueryWrapper<CrmBanner> crmBannerQueryWrapper = new QueryWrapper<>();
        crmBannerQueryWrapper.orderByDesc("sort");
        Page<CrmBanner> page = this.page(bannerPage, crmBannerQueryWrapper);
        List<CrmBanner> crmBannerList = page.getRecords();
        return crmBannerList;
    }
}




